package com.xmutca.core.netty.api;

import com.alibaba.fastjson.JSON;

import java.io.Serializable;
import java.util.UUID;

/**
 * @author: 彭伟煌(pengweihuang@xmutca.com)
 * @create: 2016-08-14 21:31
 */
public class Message implements Serializable {

    private String msgId = UUID.randomUUID().toString();

    private String to;

    private String toUsername;

    private String from;

    private String fromUsername;

    private long timestamp = System.currentTimeMillis();

    private MessageType msgType;

    public enum MessageType {
        text("text"), picture("picture"), voice("voice"), video("video"), position("position"), link("link"), notify("notify");

        private String msgType;

        MessageType(String msgType) {
            this.msgType = msgType;
        }

        public String getMsgType() {
            return msgType;
        }

        public void setMsgType(String msgType) {
            this.msgType = msgType;
        }

        @Override
        public String toString() {
            return msgType;
        }
    }

    public String getTo() {
        return to;
    }

    public void setTo(String to) {
        this.to = to;
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public MessageType getMsgType() {
        return msgType;
    }

    public void setMsgType(MessageType msgType) {
        this.msgType = msgType;
    }

    public String getMsgId() {
        return msgId;
    }

    public void setMsgId(String msgId) {
        this.msgId = msgId;
    }

    public String getToUsername() {
        return toUsername;
    }

    public void setToUsername(String toUsername) {
        this.toUsername = toUsername;
    }

    public String getFromUsername() {
        return fromUsername;
    }

    public void setFromUsername(String fromUsername) {
        this.fromUsername = fromUsername;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}